import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

class Demo3_1_5 {
    @SuppressWarnings("Convert2MethodRef")
    public static void main(String[] args) {
        List<Person> list = new ArrayList<>();
        list.add(new Person("王五", 13));
        list.add(new Person("张三", 10));
        list.add(new Person("赵六", 12));
        list.add(new Person("李四", 11));
        System.out.println("--------------- sorted 前");
        System.out.println(list);
        System.out.println("--------------- sorted 后");
        List<Person> sortedList = list.stream().sorted(Comparator.comparing(x -> x.getAge())).collect(Collectors.toList());
        System.out.println(sortedList);
    }
}